$(function(){
	/**
	 * 点击搜索按钮
	 */
	$('div span.btn_search').click(function(){
		var data = {};
		data.name = $(':input[name=search]').val();
		doDataPost(data,false,ctx+"/blog/list",function(msg){
			addPage(msg);
		});
	});

	/**
	 * 点击表格上添加按钮
	 */
	$('#add_btn').click(function(){
		var data = {};
		doDataPost(data,false,ctx+"/blog/add/form_ui",function(htmlText){
			$("div.popup_window").remove();
			addForm(htmlText);
		    openWin('blog_add_div');
		});
	});

	/**
	 * 点击表格上删除按钮
	 */
	$('#remove_btn').click(function(){
		var x = ($(window).width() - 260 + $('div.viewFramework-sidebar').width())/2;
		var y = ($(window).height() / 2 - 73);
		layer.confirm('确定要删除？', {
			icon: 3, 
			title:'提示' ,
			btn: ['确定','取消'],
			  area: ['260px', '146px'],
			  offset: [y+'px', x+'px']
		}, function(index){
			remove(ctx+"/blog/del");
		    layer.close(index);
		});
	});

	/**
	 * 双击表格弹出修改窗口
	 */
	$('table > tbody > tr').dblclick(function(){
		var id = $(this).find(':checkbox:eq(0)').val();
		var data = {};
		data['id'] = id;
		doDataPost(data,false,ctx+"/blog/edit/form_ui",function(htmlText){
			$("div.popup_window").remove();
			addForm(htmlText);
			openWin('blog_edit_div');
		});
	});

	/**
	 * 实现分页条件查询
	 */
	$('#blogListTableDiv div.my-pagination > div > a').click(function(){
		var data = {};
		data.name = $(':input[name=search]').val();
		var href = $(this).attr('href');
		//截取href中#之后的值
		var str = href.substring(1,href.Length);
		data.page=parseInt(str);
		getPageData(data,ctx+"/blog/list");
	});
	$('#blogListTableDiv div.my-pagination .page-current').change(function(){
		var data = {};
		data.mobile = $(':input[name=search]').val();
		var page = $(this).val();
		data.page=parseInt(page);
		getPageData(data,ctx+"/blog/list");
	});
	adjustTableCellWidth('blogListTableDiv');
});